package com.ycfmedical.bed.ui.fragment;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.ycfmedical.bed.R;
import com.ycfmedical.bed.adapter.UserInfoAdapter;
import com.ycfmedical.bed.bean.TextContent;
import com.ycfmedical.bed.local.DataManager;
import com.ycfmedical.bed.present.UserInfoPresenter;

import java.util.List;

import butterknife.BindView;
import cn.droidlover.xdroidmvp.mvp.XLazyFragment;
import cn.droidlover.xrecyclerview.XRecyclerContentLayout;

/**
 * Created by Administrator on 2017/2/22 0022.
 */
public class UserInfoFragment extends XLazyFragment<UserInfoPresenter> {

    @BindView(R.id.user_head_img)
    ImageView userHeadImg;

    @BindView(R.id.contentLayout)
    XRecyclerContentLayout contentLayout;

    private int id;
    private UserInfoAdapter userInfoAdapter;




    @Override
    public void initData(Bundle savedInstanceState) {
        initAdapter();
        getP().loadData();
        //userHeadImg.setImageDrawable(R.drawable.userhead_girl);
    }

    private void initAdapter() {

        userInfoAdapter = new UserInfoAdapter(context);
        contentLayout.getRecyclerView().setRefreshEnabled(false);
        contentLayout.getRecyclerView().gridLayoutManager(context, 2);
        contentLayout.getRecyclerView().setAdapter(userInfoAdapter);
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_user_info;
    }

    @Override
    public UserInfoPresenter newP() {
        return new UserInfoPresenter();
    }

    public void showData(List<TextContent> userInfo) {
        userInfoAdapter.setData(userInfo);
        userInfoAdapter.notifyDataSetChanged();
    }

    public boolean isGirl(boolean isGirl){
        if(isGirl){
            userHeadImg.setImageResource(R.drawable.userhead_girl);
        }else {
            userHeadImg.setImageResource(R.drawable.userhead_boy);
        }
        return isGirl;
}
    public static UserInfoFragment newInstance() {
        return new UserInfoFragment();
    }

}